<%--
  Created by IntelliJ IDEA.
  User: zll
  Date: 2018/5/30
  Time: 12:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>上传</title>

    <jsp:include page="../comm/comm.jsp"/>
    <script src="/myjs/webuploader.js"></script>
    <link href="/css/upload.css" rel="stylesheet"/>
</head>
<body>
<div class="layui-form" action="">
    <input type="hidden" name="id" value="${data.id}">
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">页面标题</label>
        <div class="layui-input-block">
            <input type="text" name="pagetitle"  id="pagetitle" required  lay-verify="required" placeholder="请输入页面标题" autocomplete="off" class="layui-input" value="${data.pagetitle}">
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="title"  id="title" required  lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input" value="${data.title}">
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <input type="text" name="content"  id="content" required  lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-input" value="${data.content}">
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">开始时间</label>
        <div class="layui-input-block">
            <input type="text" name="startDate"  id="startDate" required  lay-verify="required" placeholder="请输入开始时间" autocomplete="off" class="layui-input" value="${data.startDate}">
        </div>
    </div>
    <div class="layui-form-item" style="margin-top: 20px">
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-block">
            <input type="text" name="endDate"  id="endDate" required  lay-verify="required" placeholder="请输入结束时间" autocomplete="off" class="layui-input" value="${data.endDate}">
        </div>
    </div>

    <div class="layui-form-item" style="margin-top: 30px">
        <div class="layui-input-block">
            <button class="layui-btn"  lay-submit lay-filter="formDemo" id="sub">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</div>

<script type="text/javascript">

    layui.use(['form','laydate'], function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#startDate' //指定元素
        });
        laydate.render({
            elem: '#endDate' //指定元素
        });
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var  type=getQueryString("type");
            data.field.type=type;
            console.log(data.field);
            config.commPost("/activity/saveOrUpdate",data.field,function (data) {
                alert("成功");
                location.href="/page/role/listactivitys?type="+type;
            });
            return false;
        });

          function  getName(src) {
              var names=src.split("/");
              return names[4];
          }
        function getQueryString(name)
        {
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }
    });
</script>
</body>
</html>
